package com.lx.patterns.interpreter;

/**
 * @ClassName Client
 * @Description: 测试类
 * @Author: 落雪
 * @CreateDate: 2025/2/15 16:24
 * @UpdateUser: 落雪
 * @UpdateDate: 2025/2/15 16:24
 * @UpdateRemark:
 * @Version: 1.0
 */
public class Client {

    public static void main(String[] args) {
        Context context = new Context();

        Variable a = new Variable("a");
        Variable b = new Variable("b");
        Variable c = new Variable("c");
        Variable d = new Variable("d");
        Variable e = new Variable("e");

        context.assign(a, 1);
        context.assign(b, 2);
        context.assign(c, 3);
        context.assign(d, 4);
        context.assign(e, 5);

        AbstractExpression expression = new Minus(new Plus(new Plus(new Plus(a, b), c), d), e);

        System.out.println(expression + "= " + expression.interpret(context));

    }
}
